#include "mainwindow.h"

#include <QApplication>
#include <QLocale>
#include <QTranslator>


void fileread();


int N,M,w,w1,w2,num,wi,a,b,c;//N,M si string的下标 num 订单总数 wi表示finishtime的下表
int flag; //flag 表示现在是否处于爆单状态
long long finishtime[55000];//待完成订单的完成时间
char strin[10000];//用来临时存储读到的字符串
std::string sss;//用来转换的字符串

//读取文件的指针
//C:\Users\FXY\Desktop
FILE * fp = fopen("C:\\Users\\FXY\\Desktop\\menu2.txt","r");

QString sstr;
QTime baset(7,0,0);

struct menun
{
    int t,maxcap,currentcap,leavetime;
    char name[150];
}nshiwu[250];

struct menum
{
    char name[150];
    int sum;
    int kinds[150];
}mtaocan[250];


int main(int argc, char *argv[])
{
    fileread();

    QApplication a(argc, argv);

    QTranslator translator;
    const QStringList uiLanguages = QLocale::system().uiLanguages();
    for (const QString &locale : uiLanguages) {
        const QString baseName = "qt6_" + QLocale(locale).name();
        if (translator.load(":/i18n/" + baseName)) {
            a.installTranslator(&translator);
            break;
        }
    }
    MainWindow w;
    w.show();
    return a.exec();
}

// 文件读入 函数  C:\\Users\\FXY\\Desktop\\output\\cpp\\menu1.txt
void fileread()
{
    //FILE * fp = fopen("C:\\Users\\FXY\\Desktop\\output\\cpp\\menu1.txt","r");
    //char ch,c;
    //N M
    if (!feof(fp))
    {
        fscanf(fp,"%d %d",&N,&M);
    }

    //食物名字读入
    int n = 0;
    //si = 0;
    for (int i = 0; i < N; i++)
    {
        if (!feof(fp))
        {
            fscanf(fp,"%s",strin);
            strcpy(nshiwu[n++].name,strin);
            memset(strin,0,sizeof(strin));
        }

    }



    //读入制作时间 和 最大容量
    int t;
    t = n = 0;
    for (int i = 0; i < N; i++)
    {
        if (!feof(fp))
        {
            fscanf(fp,"%d",&t);
            nshiwu[i].t = t;
            nshiwu[i].leavetime = 0;
            t = 0;
            //strcpy(nshiwu[n++].name,string);
            //memset(string,0,sizeof(string));
        }

    }

    int cap;
    cap = n = 0;
    for (int i = 0; i < N; i++)
    {
        if (!feof(fp))
        {
            fscanf(fp,"%d",&cap);
            nshiwu[i].maxcap = cap;
            nshiwu[i].currentcap = 0;
            cap = 0;
            //strcpy(nshiwu[n++].name,string);
            //memset(string,0,sizeof(string));
        }

    }

    //读入 w1 w2;
    if (!feof(fp))
    {
        fscanf(fp,"%d %d",&w1,&w2);
    }

    //套餐读入
    //int m = 0;
    //si = 0;
    //int mi = 0;
    fscanf(fp,"%s",strin);
    for (int i = 0; i < M; i++)
    {

        strcpy(mtaocan[i].name,strin);
        memset(strin,0,sizeof(strin));
        int j,k;
        j = 0;
        while (!feof(fp))
        {
            fscanf(fp,"%s",strin);
            for ( k = 0; k<N ; k++)
            {
                if (strcmp(strin,nshiwu[k].name) == 0)
                {
                    mtaocan[i].kinds[j++] = k;
                    mtaocan[i].sum++;
                    memset(strin,0,sizeof(strin));
                    break;
                }
            }
            if (k == N)
            {
                break;
            }

        }

    }


}

